package com.blt.car.me.adapter;

import android.content.Context;
import android.icu.text.DecimalFormat;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.blt.car.R;
import com.blt.car.base.IBaseAdapter;
import com.blt.car.utils.StringUtils;

import blt.app_core.api.invoce.InvoiceVo;

/**
 * Created by xgp on 2017/6/29.
 */

public class BillAdapter extends IBaseAdapter {

    public BillAdapter(Context context, int resource) {
        super(context, resource);
    }


    @Override
    public View getYView(int position, View view, ViewGroup viewGroup) {

        TextView company = (TextView) view.findViewById(R.id.item_bill_company);
        TextView day = (TextView) view.findViewById(R.id.item_bill_day);
        TextView amount = (TextView) view.findViewById(R.id.item_bill_amount);
        TextView status = (TextView) view.findViewById(R.id.item_bill_status);

        InvoiceVo invoiceVo = (InvoiceVo) list.get(position);

        company.setText(invoiceVo.company);
        day.setText(StringUtils.getDay(invoiceVo.createTime));

        int index = invoiceVo.amount.indexOf(".");
        String account = invoiceVo.amount.substring(0, index);
        amount.setText(account + "元");
        if (invoiceVo.status == 0) {
            status.setText("未处理");
        } else if (invoiceVo.status == 1) {
            status.setText("已受理");
        } else if (invoiceVo.status == 2) {
            status.setText("已拒绝");
        }

        return view;
    }


}
